(function() {
    angular.module('BlurAdmin.pages.shops')
        .controller('integrateCtrl', integrateCtrl);

    function integrateCtrl($scope, $datepicker, $ShareData, $http, $filter, $myconfig, $uibModal, taRegisterTool, $openModal, $mydialog) {
        //分页
        $scope.pageChanged = function(val) {
            var Page_num = val //选中的页面数
            $scope.list_data.page = val;
            $scope.search_data();
        };


        $scope.list_data = {
            page: 1,
            limit: 10,
            name: "",
        };
        $scope.search_data = function() { //点击搜索按钮
            list_num();
        };

        //列表数据统计
        function list_num() {
            var url = $myconfig.api.COUNT_INTEGRATE_SHOP;
            var opt = {
                "name": $scope.list_data.name
            }

            $http.get(url, { params: opt })
                .then(function(res) {
                    $scope.bigTotalItems = res.data.data ? res.data.data : 0;
                    list_data();
                });
        }

        //列表数据
        function list_data() {
            var oo = new Date();
            console.log(oo.getTime());

            $http.get($myconfig.api.LIST_INTEGRATE_SHOP, { params: $scope.list_data })
                .then(function(res) {
                    if (res.data.success) {
                        for (var i = 0; i < res.data.data.length; i++) {
                            res.data.data[i].num = (($scope.list_data.page - 1) * $scope.list_data.limit) + i + 1;
                        }
                        $scope.list_data_opt = res.data.data
                    } else {
                        $mydialog.fail(res.data.data);
                    }
                });
        }
        $scope.search_data();

    }
})();